

#include "RobotFactory.h"
#include "game.h"
#include "GameObjectManager.h"

RobotFactory::RobotFactory()
{

	
}

void RobotFactory::initialize()
{
	/*m_robots.reallocate(8);

	for(int i=0;i<8;i++)
	{
		Robot* robot = GL_NEW Robot();
		robot->SetEnabled(false);
		GetGameObjectManager() ->GetGameObjects().AddObject(robot);
		m_robots.push_back(robot);
	}*/

	m_throwableObjs.reallocate(8);

	for(int i=0;i<8;i++)
	{
		ThrowableObj* throwObj = GL_NEW ThrowableObj();
		throwObj->SetEnabled(false);
		GetGameObjectManager() ->GetGameObjects().AddObject(throwObj);
		m_throwableObjs.push_back(throwObj);
	}
}

Robot* RobotFactory::getFreeRobot()
{
	for(int i=0;i<m_robots.size();i++)
		if(!m_robots[i]->IsEnabled())
		{
			m_robots[i]->reset();
			return m_robots[i];
		}
	return NULL;
}

ThrowableObj* RobotFactory::getFreeThrowableObj(int type)
{
	for(int i=0;i<m_throwableObjs.size();i++)
		if(!m_throwableObjs[i]->IsEnabled())
		{
			//m_throwableObjs[i]->reset();
			return m_throwableObjs[i];
		}
	return NULL;
}